const Mock = require('mockjs')

const data = Mock.mock({
  'items|20': [{
    id: '@id',
    bookNo: '@sentence(1, 5)',
    bookName: '@sentence(1, 5)',
    'category|1': ['mysql', 'oracle'],
    categoryId: '@uuid',
    'typeName|1': ['book', 'periodical', 'magazine'],
    type: '@uuid',
    lessee: '@name',
    'status|1': [1, 2, 3],
    lesseeId: '@uuid',
    leaseStartTime: '@datetime',
    leaseEndTime: '@datetime',
    'quote|2': [{
      id: '@uuid',
      bookNo: '@sentence(1, 5)',
      bookName: '@sentence(1, 5)'
    }],
    update: '@name',
    create: '@name',
    lastTime: '@datetime',
    creationTime: '@datetime'
  }]
})

module.exports = [
  {
    url: '/vue-admin-template/books/list',
    type: 'get',
    response: config => {
      const items = data.items
      return {
        code: 0,
        data: {
          total: items.length,
          items: items
        }
      }
    }
  }, {
    url: '/vue-admin-template/books/info',
    type: 'get',
    response: config => {
      const data = Mock.mock({
        id: '@id',
        bookNo: '@sentence(1, 5)',
        bookName: '@sentence(1, 5)',
        'category|1': ['mysql', 'oracle'],
        categoryId: ['@uuid'],
        'type|1': ['book', 'periodical', 'magazine'],
        typeId: '@uuid',
        lessee: '@name',
        lesseeId: '@uuid',
        leaseTime: '@datetime',
        'quote|2': [{
          id: '@uuid',
          bookNo: '@sentence(1, 5)',
          bookName: '@sentence(1, 5)'
        }],
        update: '@name',
        create: '@name',
        lastTime: '@datetime',
        creationTime: '@datetime'
      })
      return {
        code: 0,
        data
      }
    }
  }, {
    url: '/vue-admin-template/books/type',
    type: 'get',
    response: config => {
      return {
        code: 0,
        data: [{
          name: 'book',
          id: '@id'
        }, {
          name: 'periodical',
          id: '@id'
        }, {
          name: 'magazine',
          id: '@id'
        }]
      }
    }
  }, {
    url: '/vue-admin-template/books/category',
    type: 'get',
    response: config => {
      return {
        code: 0,
        data: [{
          name: 'mysql',
          id: '@id'
        }, {
          name: 'oracle',
          id: '@id'
        }, {
          name: 'ttt',
          id: '@id'
        }]
      }
    }
  }, {
    url: '/vue-admin-template/books/save',
    type: 'post',
    response: config => {
      return {
        code: 0,
        data: true,
        message: 'success'
      }
    }
  }, {
    url: '/vue-admin-template/books/delete',
    type: 'get',
    response: config => {
      return {
        code: 0,
        data: true
      }
    }
  }, {
    url: '/vue-admin-template/books/return',
    type: 'get',
    response: config => {
      return {
        code: 0,
        data: true
      }
    }
  }

]

